<template>
  <div>
   <ul>
    <li v-for="(item,index) in list" :key="index">{{item}}
      <button @click="del(index)">删除</button>
    </li>
   </ul>
   <button @click="fn">生成</button>
  </div>
</template>

<script>
export default {
  data(){
    return {
      list:[1,3,5],
    }
  },
  methods:{
    fn(){
      this.list.push(Math.floor(Math.random()*10))
    },
    del(id){
      this.list=this.list.filter((i,index)=> index!==id)
    }
  }
}
</script>

<style>

</style>
